let comDriver = require('../common/driver');
let Core = require('../common/Core');
// require('./test.css');

class Main {

    constructor() {
        this.core = new Core();
    }

    init() {
        comDriver.app().local_base_path = comDriver.getHrefPath( location.href);
        comDriver.app().core = this.core;
        if (comDriver.app().beans)
            for (let bean_name in comDriver.app().beans)
                comDriver.app().beans[bean_name].name = bean_name;
    }

    async start() {
        let temp = await this.core.runBeansByTags({}, true, true, 'handler', 'onBeforeSystemStart');
        if (!temp.result) return false;

        temp = await this.core.runBean('system.starter');
        if (!temp.result) return false;

        temp = await this.core.runBeansByTags({}, true, true, 'handler', 'onAfterSystemStart');
        if (!temp.result) return false;
    }

    async run() {
        this.init();

        await this.start();
    }
}




let main = new Main();

main.run();
